﻿using System.Data.SqlClient;

namespace HKEA.CMS.Core.Models.DBProvider
{
    public sealed class SqlServerProvider
    {
        /// <summary>
        /// 获取数据库连接字串
        /// </summary>
        /// <returns>连接字串</returns>
        public static string GetMySqlConnectionString()
        {
            return CH.Common.DEncrypt.DESEncrypt.Decrypt(System.Configuration.ConfigurationManager.ConnectionStrings["EDHKEA_CMSEntities"].ConnectionString);
        }
         
        /// <summary>
        /// 获取数据库连接对象
        /// </summary>
        /// <returns>数据库连接对象</returns>
        public static SqlConnection GetMySqlConnection()
        {
            //获取当前使用DataBase的数据库连接字串
            string strConnectionString = GetMySqlConnectionString();

            //创建一个新的连接(由SqlHelp决定Open与Closed的时机)
            SqlConnection sqlConn = new SqlConnection(strConnectionString);
            //返回新建的SqlConnction对象
            return sqlConn;
        }
    }
}
